package cn.readjava.service.impl;

import cn.readjava.bean.*;
import cn.readjava.dao.PermissionDao;
import cn.readjava.service.*;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@Service
@CacheConfig(cacheNames = "permission")
public class PermissionServiceImpl implements PermissionService {

    @Resource
    private PermissionDao permissionDao;

    @Override
    public Permission getOne(Long id) {
        return permissionDao.getOne(id);
    }

    @Override
    public List<Permission> findAll() {
        return permissionDao.findAll();
    }

    @Override
    @Cacheable(key = "'user-permission-id-'+ #p0")
    public Set<String> findAllPermission(long userId) {
        return permissionDao.findAllPermission(userId);
    }
}
